package com.design.pattern.structural.decorator;

import java.util.Arrays;
import java.util.List;

/**
 * @Author hanyuanlai
 * @Date 2022/7/14
 */
public class Test {
    public static void main(String[] args) {
        Student student = new Student(999);
        Shirt shirt = new Shirt();
        Pants pants = new Pants();
        Shoes shoes = new Shoes();
        shirt.dress(student);
        pants.dress(shirt);
        shoes.dress(pants);
        shoes.chuanyifu();

        Bread bread = new Bread(1);
        Soup soup = new Soup(2);
        Apple apple = new Apple(3);

        List<Person> people = Arrays.asList(bread, soup, apple, student);
        people.sort((a, b) -> b.order - a.order);
        for (int i = 1, foodsSize = people.size(); i < foodsSize; i++) {
            people.get(i).decorate(people.get(i-1));

        }
        people.get(people.size() - 1).eat();
    }
}
